import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import { IsDate, IsEnum, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator'
import { StudentStatus, StudentType } from '../entities/student.entity'

export class CreateStudentDto {
  @ApiProperty({ description: '手机号' })
  @IsString()
  @IsNotEmpty()
  @IsPhoneNumber('CN')
  phone: string

  @ApiProperty({ description: '用户昵称/姓名' })
  @IsString()
  @IsNotEmpty()
  userName: string

  @ApiProperty({ description: '密码' })
  @IsString()
  @IsNotEmpty()
  password: string

  @ApiProperty({ description: '关联用户ID' })
  @IsInt()
  @IsNotEmpty()
  userId: number

  @ApiProperty({ description: '学习方式，1 线上学习 2 线下学习', enum: StudentType, default: StudentType.ONLINE })
  @IsEnum(StudentType)
  @IsOptional()
  studentType?: StudentType

  @ApiProperty({ description: '开始时间' })
  @Type(() => Date)
  @IsDate()
  @IsNotEmpty()
  startAt: Date

  @ApiProperty({ description: '结束时间' })
  @Type(() => Date)
  @IsDate()
  @IsNotEmpty()
  expireAt: Date

  @ApiProperty({ description: '学生状态， 0 已停用 1 学习中 2 待续费 4 已毕业', enum: StudentStatus, default: StudentStatus.STUDYING })
  @IsEnum(StudentStatus)
  @IsOptional()
  status?: StudentStatus
}
